#!/bin/sh
echo $VIRTUAL_ENV
echo "Installation requires a Python Virtual Environment!"
read
pwd=`pwd`
if [ "$VIRTUAL_ENV" = "" ]; then
	echo "No python virtual environment detected."
	echo "exit."
	exit 1
fi
echo "Current activated Python Virtual Environment is " "$VIRTUAL_ENV"
read
rm -rf /tmp/crane
mkdir /tmp/crane
chmod -R 777 /tmp/crane

rm -f $VIRTUAL_ENV/bin/start-crane-*
rm -f $VIRTUAL_ENV/bin/stop-crane-*
rm -f $VIRTUAL_ENV/bin/crane-task-queue
rm -f $VIRTUAL_ENV/bin/crane-task-queue-sched

rm -rf /etc/crane

cd $VIRTUAL_ENV/bin

ln -s $pwd/api_server/crane.server/craneserver/bin/* ./

mkdir /etc/crane

cd /etc/crane

ln -s $pwd/api_server/crane.server/craneserver/etc/* ./

cd /var/www

ln -s $pwd/api_server/crane.server/craneserver/public ./crane

cd $pwd/api_server/crane.server

python setup.py develop

cd $pwd/craneconfig

python setup.py develop

cd $pwd
